<Project TreatAsLocalProperty="TaskFolder;TaskAssembly">

  <PropertyGroup>
    <TaskFolder Condition=" '$(MSBuildRuntimeType)' == 'Core' ">net6.0</TaskFolder>
    <TaskFolder Condition=" '$(MSBuildRuntimeType)' != 'Core' ">net472</TaskFolder>
    <TaskAssembly>$(MSBuildThisFileDirectory)..\tasks\$(TaskFolder)\ConventionalCommitsGitInfo.dll</TaskAssembly>
  </PropertyGroup>

  <UsingTask TaskName="ConventionalCommitsGitInfo.GitVersion" AssemblyFile="$(TaskAssembly)" />

  <PropertyGroup>
    <!-- The version from which automatic versioning will start. -->
    <ConventionalCommitsGitInfo_BaseVersion>0.1.0</ConventionalCommitsGitInfo_BaseVersion>
    <!-- ID of the last commit before automatic versioning started. -->
    <ConventionalCommitsGitInfo_BaseCommit></ConventionalCommitsGitInfo_BaseCommit>
    <!-- Maximum number of countable commits per category. -->
    <ConventionalCommitsGitInfo_ReleaseNotesCount>10</ConventionalCommitsGitInfo_ReleaseNotesCount>
    <!-- Indicates the importance of messages. Use for debugging. -->
    <ConventionalCommitsGitInfo_MessageImportance>low</ConventionalCommitsGitInfo_MessageImportance>
  </PropertyGroup>

  <Target Name="SetSemanticVersion" BeforeTargets="PrepareForBuild;DispatchToInnerBuilds">
    <GitVersion 
      BaseCommit="$(ConventionalCommitsGitInfo_BaseCommit)" 
      BaseVersion="$(ConventionalCommitsGitInfo_BaseVersion)"
      ReleaseNotesCount="$(ConventionalCommitsGitInfo_ReleaseNotesCount)">
      <Output TaskParameter="Version" PropertyName="_Version" />
      <Output TaskParameter="ReleaseNotes" PropertyName="_ReleaseNotes" />
    </GitVersion>

    <PropertyGroup>
      <Version>$(_Version)</Version>
      <FileVersion>$(Version)</FileVersion>
      <PackageVersion>$(Version)</PackageVersion>
      <PackageReleaseNotes>$(_ReleaseNotes)</PackageReleaseNotes>
    </PropertyGroup>

    <Message Importance="$(ConventionalCommitsGitInfo_MessageImportance)" Text="You are using ConventionalCommitsGitInfo. Your properties will be set automatically:" />
    <Message Importance="$(ConventionalCommitsGitInfo_MessageImportance)" Text="Version: $(Version)" />
    <Message Importance="$(ConventionalCommitsGitInfo_MessageImportance)" Text="Release Notes:" />
    <Message Importance="$(ConventionalCommitsGitInfo_MessageImportance)" Text="$(PackageReleaseNotes)" />
  </Target>

</Project>
